package com.ailiwu.www.ailiwu.activity;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.ailiwu.www.ailiwu.R;
import com.ailiwu.www.ailiwu.base.BaseActivity;

public class PurchaseActivity extends BaseActivity {
    private String purchase_url;
    private WebView wv_purchase;
    private Toolbar toolbar;
    @Override
    protected void loadXml() {
        setContentView(R.layout.activity_purchase);
    }

    @Override
    protected void getIntentData(Bundle savedInstanceState) {
        purchase_url = getIntent().getStringExtra("PURCHASE_URL");
    }

    @Override
    protected void initView() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowCustomEnabled(true);

        wv_purchase = (WebView) findViewById(R.id.wv_purchase);
        WebSettings webSettings = wv_purchase.getSettings();
        webSettings.setDefaultTextEncodingName("UTF-8");
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        wv_purchase.setWebViewClient(new WebViewClient());
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void initData() {
        wv_purchase.loadUrl(purchase_url);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()){
            case android.R.id.home:
                finish();
                break;
            default:
                break;
        }
        return super.onOptionsItemSelected(item);
    }
}
